
package CtrlLayer;
import ModelLayer.StandardTask;
import DBLayer.IFDBStandardTask;
import DBLayer.DBStandardTask;
import java.util.ArrayList;

/**
 * @version 12/22/2011
 * @author Gruppe 4
 */

public class CtrlStandardTask 
{
    private IFDBStandardTask dbStTask;
    private StandardTask stTaskObj;
    
    /**
     * Constructor for class CtrlStandardTask
     */
    public CtrlStandardTask()
    {
        dbStTask = new DBStandardTask();
        stTaskObj = new StandardTask();
    }
    
    /**
     * Method to get all StandardTasks from the database
     * @return returns an ArrayList with all StandardTasks
     */
    public ArrayList<StandardTask> findAllStandardTasks()
    {
        return dbStTask.getAllStandardTasks();
    }
    
    /**
     * Method that calls to get a StandardTask with a specific Id
     * @param standardTaskId int standardTaskId the id of the standardTask
     * @return returns a StandardTask Object
     */
    public StandardTask findStandardTask(int standardTaskId)
    {
        return dbStTask.searchStandardTask(standardTaskId);
    }
    
    /**
     * Method to insert a new StandardTask in the database
     * @param name String name the name of the standardTask
     * @param String description the description of the standardTask
     * @param standardDisclaimer String standardDisclaimer the standardDisclaimer of StandardTask
     */
    public void insertNewStandardTask(String name, String description, String standardDisclaimer)
    { 
        stTaskObj.setName(name);
        stTaskObj.setDescription(description);
        stTaskObj.setStandardDisclaimer(standardDisclaimer);
        dbStTask.insertStandardTask(stTaskObj);
    }
    
    /**
     * Method to update a StandardTask
     * @param standardTaskId int standardTaskId the id of the standardTask
     * @param name String name the name of the standardTask
     * @param description String description the description of the standardTask
     * @param standardDisclaimer String standardDisclaimer the standardDisclaimer of StandardTask
     * @return returns an int 1 if the method succedes and -1 if the method fails
     */
    public int updateStandardTask(int standardTaskId, String name, String description, String standardDisclaimer)
    {
        stTaskObj.setStandardTaskId(standardTaskId);
        stTaskObj.setName(name);
        stTaskObj.setDescription(description);
        stTaskObj.setStandardDisclaimer(standardDisclaimer);
        return dbStTask.updateStandardTask(stTaskObj);
    }  
    
    /**
     * Method to delete a StandardTask from the database
     * @param standardTaskId int standardTaskId the id of the standardTask
     */
    public void deleteStandardTask(int standardTaskId )
    {
        dbStTask.deleteStandardTask(standardTaskId);
    }
}